package com.chx.ajxtest.controller;

import com.chx.ajxtest.bean.User;
import com.chx.ajxtest.commom.ResultInfo;
import com.chx.ajxtest.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public ResultInfo pass(@RequestBody User user) {
        ResultInfo re = new ResultInfo();
        try {
            userService.pass(user);
            re.setOk();
            re.setData(user);
        } catch (Exception e) {
            e.printStackTrace();
            re.setError();
        }
        return re;
    }
}
